/* 1.程序功能：读取手柄按键是否被按下
/* 2.使用函数：PS2ButtonPressed(HteJOYSTICK_UP) 
 *      函数类型：布尔类型
 * 3.函数参数可用      HteJOYSTICK_UP   //上键
 *                   HteJOYSTICK_DOWN //下键
 *                   HteJOYSTICK_LEFT //左键
 *                   HteJOYSTICK_RIGHT //右键
 *                   HteJOYSTICK_Y    //Y键
 *                   HteJOYSTICK_B    //B键
 *                   HteJOYSTICK_A    //A键
 *                   HteJOYSTICK_X    //X键
 *                   HteJOYSTICK_ZR   //ZR键
 *                   HteJOYSTICK_ZL   //ZL键
 *                   HteJOYSTICK_L    //L键
 *                   HteJOYSTICK_R    //R键
 *                   HteJOYSTICK_MINUS   //减号键
 *                   HteJOYSTICK_PLUS    //加号键
 *                   HteJOYSTICK_MODE    //MODE键
 *                   HteJOYSTICK_HOME    //HOME键
 *                   HteJOYSTICK_BUTTON_L //左button键
 *                   HteJOYSTICK_BUTTON_R //右button键
 * 4.数组值的范围True or False
 */
#include <bluetooth_ps2.h>
void setup() {
  Serial.begin(115200); //初始化ps2所需串口
}

void loop() {
  ps2loop(Serial);//读取手柄发来的信息
  if(PS2ButtonPressed(HteJOYSTICK_UP)) //判断上键是否被按下
    Serial.println("UP pressed");
  if(PS2ButtonPressed(HteJOYSTICK_DOWN))//判断下键是否被按下
    Serial.println("DOWN pressed");
  if(PS2ButtonPressed(HteJOYSTICK_LEFT))//判断左键是否被按下
    Serial.println("LEFT pressed");
  if(PS2ButtonPressed(HteJOYSTICK_RIGHT))//判断右键是否被按下
    Serial.println("RIGHT pressed");
  delay(100);
}
